//
// Copyright (c) 2010 xiaoningyb (xiaoningyb@gmail.com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//

#ifndef TINYSHARING_CLIENT_H
#define TINYSHARING_CLIENT_H

#include <boost/asio.hpp>
#include <string>
#include <vector>
#include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>
#include "sharing_connection.h"
#include "request_handler.h"

namespace tinysharing
{    
    class client
    {
    public:
        /// Constructor starts the asynchronous connect operation.
        client(boost::asio::io_service& io_service, const std::string& host,
               const std::string& service);
    
        /// Handle completion of a connect operation.
        void handle_connect(const boost::system::error_code& e,
                            boost::asio::ip::tcp::resolver::iterator endpoint_iterator);

        /// Handle completion of a read operation.
        void handle_read(const boost::system::error_code& e);    

    private:
        /// The connection to the server.
        connection connection_;

        /// The handler for server reply
        request_handler reply_handler_;

        /// The data received from the server.
        sharing_message message_;
    };

} // namespace tinysharing

#endif // TINYSHARING_CLIENT_H
